package cyb.test;

import cyb.POI;
import cyb.Properties;
import cyb.Util;

import java.io.IOException;
import java.util.*;

import static cyb.CoLocation.getPOIFromFile;


//import static cyb.CoLocation.getOldNeighborsFromFile;
//import static cyb.CoLocation.getPOIFromFile;

public class test2 {

    public static void main(String[] args) throws IOException {
        Map<String, POI> poiMap = getPOIFromFile(Properties.maxNum);
        //109,173,537
        POI poi1 = poiMap.get("6263");// id=6263, name='延庆影剧院', type='109', X=115.988493, Y=40.463616
        System.out.println(poi1);
        POI poi2 = poiMap.get("7214");// id=7214, name='创明视眼镜', type='173', X=115.981468, Y=40.461111
        System.out.println(poi2);
        POI poi3 = poiMap.get("6065");// id=6065, name='宝之林(延庆分店)', type='537', X=115.978455, Y=40.465154
        System.out.println(poi3);
        System.out.println(Util.getEarthDistance(poi1.getXY(), poi2.getXY()));
        System.out.println(Util.getEarthDistance(poi1.getXY(), poi3.getXY()));
        System.out.println(Util.getEarthDistance(poi3.getXY(), poi2.getXY()));
//        System.out.println(Properties.Method.JOIN_BASE.equals("both"));

    }
    public static void findStarInstance(List<String[]> list, int i, String str, List<String> result) {
        //当前获取的第i个特征实例
        if (i == list.size() - 1) {
            result.add(str);
            return;
        }
        String[] arr = list.get(i);
        for (String st : arr) {
            str = str + "," + st;
            findStarInstance(list, i + 1, str, result);
        }
    }
    public static void setCompare(Set<String> set1, Set<String> set2) {
        Set<String> result = new HashSet<String>();
        System.out.println("set1 = " + set1.toString());
        System.out.println("set2 = " + set2.toString());

        result.clear();
        result.addAll(set1);
        result.retainAll(set2);
//        System.out.println("交集：" + result);

        Set<String> result2 = new HashSet<String>();
        result2.addAll(set1);
        result2.addAll(set2);
//        System.out.println("并集：" + result2);

        result2.removeAll(result);
        System.out.println("差集：" + result2);

        result.clear();
        result.addAll(set1);
        result.removeAll(set2);
        System.out.println("在1不在2的差集：" + result);

        result.clear();
        result.addAll(set2);
        result.removeAll(set1);
        System.out.println("在2不在1的差集：" + result);
    }

    public static String stringToAscii(String value) {
        StringBuffer sbu = new StringBuffer();
        char[] chars = value.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            if (i != chars.length - 1) {
                sbu.append((int) chars[i]).append(",");
            } else {
                sbu.append((int) chars[i]);
            }
        }
        return sbu.toString();
    }


}